package com.pansoft.openplanet.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.efounder.utils.NumberTextWatcher;
import com.pansoft.openplanet.R;
import com.utilcode.util.KeyboardUtils;


public class SetExchangeNumberActivity extends TCBaseActivity {


    private TextView titleText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_set_exchange_num);
        initView();
        initData();
    }

    private void initData() {
        titleText.setText(getResources().getString(R.string.open_planet_asset_set_deal_num));
    }

    private void initView() {
        final EditText editText = (EditText) findViewById(R.id.openplant_exchange_number);
        Button confirm = (Button) findViewById(R.id.openplant_confirm_button);
        titleText = (TextView) findViewById(R.id.tv_title);
        editText.setSelection(editText.getText().length());
        editText.post(new Runnable() {
            @Override
            public void run() {
                editText.setFocusableInTouchMode(true);
                editText.requestFocus();
                KeyboardUtils.showSoftInput(editText);
            }
        });
        editText.addTextChangedListener(new NumberTextWatcher(editText));
        confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String money = editText.getText().toString();
                Intent intent = new Intent();
                intent.putExtra("money", money);
                setResult(RESULT_OK, intent);
                finish();
            }
        });
    }
}
